import instance from "../utils/Request"

//  请求总数据
export let get_list = () => {
    return async(dispatch) => {
        let {data} = await instance.get("/api/data")
        console.log(data);
        dispatch({
            type:"GET_LIST",
            payload:data
        })
    }
}

//切换tabs子数据
export let set_children = (v) => { 
    return {
        type:"SET_CHILDREN",
        payload:v
    }
}

//筛选数据
export let  filter_childrenData = (v) => {
    return {
        type:"FILTER_DATA",
        payload:v.value
    }
}

// 排序
export let sort_children = (v) => {
    return {
        type:"SORT_DATA",
        payload:v.value
    }
}

//添加购物车
export let add_shopCar = (id) => {
    return {
        type:"ADD_SHOPCAR",
        payload:id
    }
}

//收藏
export let set_like = (id) => {
    return {
        type:"SET_LIKE",
        payload:id
    }
}

//购物车 ++
export let add_shopcar_count = (item) => {
    return {
        type:"ADD_SHOPCAR_COUNT",
        payload:item
    }
}

// 购物车 -- 
export let del_shopcar_count = (item) => {
    return {
        type:"DEL_SHOPCAR_COUNT",
        payload:item
    }
}

// 删除购物车车商品
export let del_shopcar = (item) =>{
    return {
        type:"DEL_SHOPCAR",
        payload:item
    }
}

// 单选
export let set_shopcar_checked = (item) =>{
    return {
        type:"SET_SHOPCAR_CHECK",
        payload:item
    }
}

// 全选
export let all_shopcar_checked = (checked) =>{
    return {
        type:"ALL_SHOPCAR_CHECKED",
        payload:checked
    }
}

// 全部删除

export let All_del_shopcar = () =>{
    return {
        type:"ALL_DEL_SHOPCAR",
      
    }
}